#include "my_checkbox.h"

my_checkbox::my_checkbox(char* name , bool enable , QWidget* parent) : QWidget(parent)
{
    this->checkbox = new QCheckBox(name);
    this->hboxlayout = new QHBoxLayout();
    this->hboxlayout->setMargin(0);
    this->hboxlayout->setSpacing(0);
    this->setLayout(this->hboxlayout);

    this->checkbox->setTristate(0);
    this->hboxlayout->addWidget(this->checkbox);
    if(0 == enable)
    {
        //this->checkbox->setAttribute(Qt::WA_TransparentForMouseEvents);

    }

    QObject::connect(this , SIGNAL(set_clicked_signal(bool)) , this , SLOT(set_clicked_slot(bool)));


}

my_checkbox::~my_checkbox()
{
    delete this->checkbox;
    delete this->hboxlayout;

}


my_checkbox::my_checkbox(char* name , bool enable , bool entristate, QWidget* parent) : QWidget(parent)
{
    this->checkbox = new QCheckBox(name);
    this->hboxlayout = new QHBoxLayout();
    this->hboxlayout->setMargin(0);
    this->hboxlayout->setSpacing(0);
    this->setLayout(this->hboxlayout);


    if(1 == entristate)
        this->checkbox->setTristate(0);
    else
        this->checkbox->setTristate(0);


    this->hboxlayout->addWidget(this->checkbox);
    if(0 == enable)
    {
        //this->checkbox->setAttribute(Qt::WA_TransparentForMouseEvents);
    }
    QObject::connect(this , SIGNAL(set_clicked_signal(bool)) , this , SLOT(set_clicked_slot(bool)));
}




void my_checkbox::set_clicked(bool enable)
{
    emit this->set_clicked_signal(enable);
}

void my_checkbox::set_clicked_slot(bool enable)
{
    if(enable)
        this->checkbox->setCheckState(Qt::Checked);
    else
        this->checkbox->setCheckState(Qt::Unchecked);
}
